import React from 'react';
import {message, Modal,Tag} from 'antd';
import Nprogress from 'nprogress'
import 'nprogress/nprogress.css'
import {AlignCenterOutlined} from '@ant-design/icons'
// import ExportJsonExcel from "js-export-excel";
import {Tooltip,Image} from 'antd'

import classNames from 'classnames'
import axios from 'axios'

const {
    REACT_APP_FILE_URL,
    REACT_APP_PROJECT_NAME,
} = process.env;

Nprogress['configure']({showSpinner: false})
const {confirm} = Modal;
const commonConfig = {
    // url: REACT_APP_SERVER_URL,
    url: "http://139.224.81.105/19999",
    fileUrl: REACT_APP_FILE_URL,
    react_project_name: REACT_APP_PROJECT_NAME,
    projectName: 'react_template_admin',
    pageNumber: 1,
    pageSize: 10,
    totalRow: 0,
    isLogin: false,

    options: {
        letterList: ['A', 'B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R', 'S','T','U','V','W','X','Y','Z'],
        regex: {
            allView: /(docx|txt|json|xls|xlsx|csv|pdf|mp3|mp4|jpg|png|jpeg|gif|xml|js|jsx|ts)$/,
            doc: /(pdf|docx|xls|xlsx|csv|txt|xml|json|js|jsx|ts)$/,
            image: /(jpg|png|jpeg|gif)$/,
            audio: /(mp3)$/,
            video: /(mp4)$/,
            otherDoc: /(js|jsx|ts)$/,
            excel: /(xlsx|xls|csv)$/,
            word: /(docx)$/,
            ppt: /(pptx)$/,
            commonTxt: /(xml|js|jsx|ts)$/
        }
    },
    /**
     * 设置地址栏URL参数  返回react-router-dom search的参数
     * @param params
     * @returns {string}
     */
    setUrlParams(params) {
        let paramsArr = [];
        for (const paramsKey in params) {
            if (params.hasOwnProperty(paramsKey))
                paramsArr.push(paramsKey + '=' + encodeURIComponent(encodeURIComponent(params[paramsKey])));
        }
        return paramsArr.join('&');
    },
    /**
     * 页面跳转
     * @param _this
     * @param pathname
     * @param params
     */
    redirectPage(props, pathname, params) {
        props.history.push({
            pathname: pathname ? '/view/' + pathname : '/view',
            search: this.setUrlParams(params || {})
        });
    },
    /**
     * 页面跳转默认
     * @param _this
     * @param pathname
     * @param params
     */
    redirectPageDefault(_this, pathname, params) {
        _this.props.history.push({
            pathname: pathname ? '/' + pathname : '/view',
            search: this.setUrlParams(params || {})
        });
    },
    /**
     * 页面跳转-打开新窗口
     * @param pathname
     * @param params
     */
    redirectPageOpen(pathname, params) {
        let origin = window.location.origin + process.env.REACT_APP_PROJECT_NAME + '/#';
        window.open(origin + (pathname ? ('/' + pathname + '?') : '/view') + this.setUrlParams(params));
    },
    /**
     * 获取url参数并返回对象
     * @param _this
     */
    getUrlParams(_this) {
        const {search} = _this.location;
        let params = decodeURIComponent(decodeURIComponent(search));
        if (!params) return {};
        params = params.substring(params.lastIndexOf('?') + 1);
        params = params.split('&');
        let resultObj = {};
        for (const paramsKey in params) {
            let param = params[paramsKey].split('=');
            resultObj[param[0]] = param[1];
        }
        return resultObj;
    },
    // 获取页面操作的权限
 getPageJurisdiction (status,createBy,userName){
    switch(status) {
      case 'N':
        if(userName===createBy){
          return true
        } else {
          return false
        }
      case 'PN':
        if(userName===createBy){
          return true
        } else {
          return false
        }
      default:
        return false
    }
  },
  // 获取状态切换的权限
   getStatusJurisdiction(status,createBy,rmanager,qmanager,userName,role) {
    switch(status) {
      case 'N':
        if(userName===createBy){
          return ['N','R']
        } else {
          return []
        }
      case 'PN':
       if(userName===createBy){
         return ['PN','PR']
       } else {
         return []
       }
      case 'R':
        if(userName===rmanager){
          return ['N','R','Q']
        } else {
          return ['N']
        }
        case 'PR':
          if(userName===rmanager){
            return ['PN','PR','PQ']
          } else {
            return ['PN']
          }
       case 'Q':
        if(userName===qmanager){
          return ['N','Q','P']
        } else {
          return ['PN']
        }
        case 'PQ':
          if(userName===qmanager){
            return ['PN','PQ','P']
          } else {
            return ['PN']
          }
       case 'P':
        if(role){
          return ['PN']
        } else {
          return []
        }
      default:
        return []
    }
  },
  getStatusIndex (value) {
    switch(value) {
      case 'N':
        return 0
      case 'PN':
        return 0
      case 'R':
        return 1
      case 'PR':
        return 1
      case 'Q' :
        return 2
      case 'PQ':
        return 2
       case 'P':
        return 3
      default:
        return
    }
  },
  // 获取对应的值
 statusValue(value,status) {
    if( ['N','R','Q'].includes(status)){
      switch(value){
        case 0:
        return 'N'
        case 1:
       return 'R'
       case 2:
       return 'Q'
       case 3:
       return 'P'
       default:
         return ''
      }
    } else {
      switch(value){
        case 0:
        return 'PN'
        case 1:
       return 'PR'
       case 2:
       return 'PQ'
       case 3:
        return 'P'
        default:
          return ''
      }
    }
  },
  getColumns(value,goInfo,userName){
    switch (value) {
      case '1':
      return [
        {title: '单词', dataIndex: 'wordName', key: 'wordName', align: 'center',render: (text, record) => {
          return <div className="operate_link_group text-nowrap text-link" onClick={()=>goInfo(record.id,'WORD')}>
            {text}
         </div>
       }},
        {title: '词性', dataIndex: 'pofName', key: 'pofName', align: 'center'},
        {title: '状态', dataIndex: 'wordStatus', key: 'wordStatus', align: 'center'},
        {title: '级别', dataIndex: 'levelName', key: 'levelName', align: 'center'},
        {title: '标签', dataIndex: 'labels', key: 'labels',width:150, align: 'center', render: (text, record) => {
         return <div className="operate_link_group text-nowrap">
          {record.labels?.map((i,j)=>{
            return   <Tooltip key={i.id} placement="top" title={text.map(i=>i.labelName).join(' ')}>
             {
               j<3?<Tag key={i.id} color="green">{i.labelName}</Tag>:''
             }
              </Tooltip>
          })}
        </div>
      }},
        {title: '创建人', dataIndex: 'createBy', key: 'createBy', align: 'center',render: (text, record) => {
          return <div className={classNames(userName===text?'operate_link_group text-nowrap text-color-red':"operate_link_group text-nowrap")}>
            {text}
         </div>
       }},
        {title: '负责人', dataIndex: 'manager', key: 'manager', align: 'center', render: (text, record) => {
          return <div className={classNames((userName===record.qmanager)||(userName===record.rmanager)?'operate_link_group text-nowrap text-color-red':"operate_link_group text-nowrap")}>
          {record.qmanager||record.rmanager}
         </div>
       }},
        {title: '更新人', dataIndex: 'updateBy', key: 'updateBy', align: 'center',render: (text, record) => {
          return  <div className={classNames(userName===text?'operate_link_group text-nowrap text-color-red':"operate_link_group text-nowrap")}>
          {text}
       </div>
       }},
        {title: '更新时间', dataIndex: 'updateTime', key: 'updateTime', align: 'center',width:150}
      ]
      case '2':
      return [
        {title: '名称',fixed:'left', dataIndex: 'songName',width:250, key: 'songName', align: 'center',render: (text, record) => {
          return <div className="operate_link_group text-nowrap text-link" onClick={()=>goInfo(record.id,'SONG')}>
            {text}
         </div>
       }},
        {title: '状态', dataIndex: 'songStatus',width:100, key: 'songStatus', align: 'center'},
        {title: '适合年纪', dataIndex: 'ageName',width:100, key: 'ageName', align: 'center'},
        {title: '发行方', dataIndex: 'publisher',width:150, key: 'publisher', align: 'center'},
        {title: '主题', dataIndex: 'themes',width:180, key: 'themes', align: 'center', render: (text, record) => {
          return <div className="operate_link_group text-nowrap">
           {record.themes?.map((i,j)=>{
             return   <Tooltip key={i.id} placement="top" title={text.map(i=>i.themeName).join(' ')}>
              {
                j<3?<Tag key={i.id} color="lime">{i.themeName}</Tag>:''
              }
               </Tooltip>
           })}
         </div>}
        },
        {title: '系列', dataIndex: 'serialName',width:150, key: 'serialName', align: 'center'},
        {title: '类型', dataIndex: 'songCategoryName',width:150, key: 'songCategoryName', align: 'center'},
        {title: '标签', dataIndex: 'labels', key: 'labels',width:180, align: 'center', render: (text, record) => {
         return <div className="operate_link_group text-nowrap">
          {record.labels?.map((i,j)=>{
            return   <Tooltip key={i.id} placement="top" title={text.map(i=>i.labelName).join(' ')}>
             {
               j<3?<Tag key={i.id} color="green">{i.labelName}</Tag>:''
             }
              </Tooltip>
          })}
        </div>
      }},
        {title: '创建人',width:120, dataIndex: 'createBy', key: 'createBy', align: 'center',render: (text, record) => {
          return <div className={classNames(userName===text?'operate_link_group text-nowrap text-color-red':"operate_link_group text-nowrap")}>
            {text}
         </div>
       }},
        {title: '负责人',width:120, dataIndex: 'manager', key: 'manager', align: 'center', render: (text, record) => {
          return <div className={classNames((userName===record.qmanager)||(userName===record.rmanager)?'operate_link_group text-nowrap text-color-red':"operate_link_group text-nowrap")}>
          {record.qmanager||record.rmanager}
         </div>
       }},
        {title: '更新人',width:120, dataIndex: 'updateBy', key: 'updateBy', align: 'center',render: (text, record) => {
          return  <div className={classNames(userName===text?'operate_link_group text-nowrap text-color-red':"operate_link_group text-nowrap")}>
          {text}
       </div>
       }},
        {title: '更新时间', dataIndex: 'updateTime', key: 'updateTime', align: 'center',width:150},
        {title: '操作',fixed:'right', dataIndex: 'operate', key: 'operate', align: 'center',width:100,render:()=>{
          return  <div className="text-link">
           预览
         </div>
        }}
      ]
      case '3':
      return [
        {title: '名称',fixed:'left', dataIndex: 'videoName',width:250, key: 'videoName', align: 'center',render: (text, record) => {
          return <div className="operate_link_group text-nowrap text-link" onClick={()=>goInfo(record.id)}>
            {text}
         </div>
       }},
        {title: '状态', dataIndex: 'videoStatus',width:100, key: 'videoStatus', align: 'center'},
        {title: '封面', dataIndex: 'pictureUrl',width:150, key: 'pictureUrl', align: 'center',render:(text)=>{
          return  <div>
            {
              text?<Image
              width={60}
              src={text}
            />:''
            }
          </div>
        }},
        {title: '适合年纪', dataIndex: 'ageName',width:100, key: 'ageName', align: 'center'},
        {title: '发行方', dataIndex: 'publisher',width:150, key: 'publisher', align: 'center'},
        {title: '主题', dataIndex: 'themes',width:180, key: 'themes', align: 'center', render: (text, record) => {
          return <div className="operate_link_group text-nowrap">
           {record.themes?.map((i,j)=>{
             return   <Tooltip key={i.id} placement="top" title={text.map(i=>i.themeName).join(' ')}>
              {
                j<3?<Tag key={i.id} color="lime">{i.themeName}</Tag>:''
              }
               </Tooltip>
           })}
         </div>}
        },
        {title: '系列', dataIndex: 'serialName',width:150, key: 'serialName', align: 'center'},
        {title: '类型', dataIndex: 'videoCategoryName',width:150, key: 'videoCategoryName', align: 'center'},
        {title: '标签', dataIndex: 'labels', key: 'labels',width:180, align: 'center', render: (text, record) => {
         return <div className="operate_link_group text-nowrap">
          {record.labels?.map((i,j)=>{
            return   <Tooltip key={i.id} placement="top" title={text.map(i=>i.labelName).join(' ')}>
             {
               j<3?<Tag key={i.id} color="green">{i.labelName}</Tag>:''
             }
              </Tooltip>
          })}
        </div>
      }},
        {title: '创建人',width:120, dataIndex: 'createBy', key: 'createBy', align: 'center',render: (text, record) => {
          return <div className={classNames(userName===text?'operate_link_group text-nowrap text-color-red':"operate_link_group text-nowrap")}>
            {text}
         </div>
       }},
        {title: '负责人',width:120, dataIndex: 'manager', key: 'manager', align: 'center', render: (text, record) => {
          return <div className={classNames((userName===record.qmanager)||(userName===record.rmanager)?'operate_link_group text-nowrap text-color-red':"operate_link_group text-nowrap")}>
          {record.qmanager||record.rmanager}
         </div>
       }},
        {title: '更新人',width:120, dataIndex: 'updateBy', key: 'updateBy', align: 'center',render: (text, record) => {
          return  <div className={classNames(userName===text?'operate_link_group text-nowrap text-color-red':"operate_link_group text-nowrap")}>
          {text}
       </div>
       }},
        {title: '更新时间', dataIndex: 'updateTime', key: 'updateTime', align: 'center',width:150},
        {title: '操作',fixed:'right', dataIndex: 'operate', key: 'operate', align: 'center',width:100,render:()=>{
          return  <div className="text-link">
           预览
         </div>
        }}
      ]
      case '4':
      return [
        {title: '名称',fixed:'left', dataIndex: 'albumVideoName',width:250, key: 'albumVideoName', align: 'center',render: (text, record) => {
          return <div className="operate_link_group text-nowrap text-link" onClick={()=>goInfo(record.id,'ALBUM_VIDEO')}>
            {text}
         </div>
       }},
        {title: '状态', dataIndex: 'albumVideoStatus',width:100, key: 'albumVideoStatus', align: 'center'},
        {title: '封面', dataIndex: 'pictureUrl',width:150, key: 'pictureUrl', align: 'center',render:(text)=>{
          return  <div>
            {
              text?<Image
              width={60}
              src={text}
            />:''
            }
          </div>
        }},
        {title: '适合年纪', dataIndex: 'ageName',width:100, key: 'ageName', align: 'center'},
        {title: '发行方', dataIndex: 'publisher',width:150, key: 'publisher', align: 'center'},
        {title: '主题', dataIndex: 'themes',width:180, key: 'themes', align: 'center', render: (text, record) => {
          return <div className="operate_link_group text-nowrap">
           {record.themes?.map((i,j)=>{
             return   <Tooltip key={i.id} placement="top" title={text.map(i=>i.themeName).join(' ')}>
              {
                j<3?<Tag key={i.id} color="lime">{i.themeName}</Tag>:''
              }
               </Tooltip>
           })}
         </div>}
        },
        {title: '系列', dataIndex: 'avSerialName',width:150, key: 'avSerialName', align: 'center'},
        {title: '集数', dataIndex: 'count',width:100, key: 'count', align: 'center'},
        {title: '类型', dataIndex: 'videoCategoryName',width:150, key: 'videoCategoryName', align: 'center'},
        {title: '标签', dataIndex: 'labels', key: 'labels',width:180, align: 'center', render: (text, record) => {
         return <div className="operate_link_group text-nowrap">
          {record.labels?.map((i,j)=>{
            return   <Tooltip key={i.id} placement="top" title={text.map(i=>i.labelName).join(' ')}>
             {
               j<3?<Tag key={i.id} color="green">{i.labelName}</Tag>:''
             }
              </Tooltip>
          })}
        </div>
      }},
        {title: '创建人',width:120, dataIndex: 'createBy', key: 'createBy', align: 'center',render: (text, record) => {
          return <div className={classNames(userName===text?'operate_link_group text-nowrap text-color-red':"operate_link_group text-nowrap")}>
            {text}
         </div>
       }},
        {title: '负责人',width:120, dataIndex: 'manager', key: 'manager', align: 'center', render: (text, record) => {
          return <div className={classNames((userName===record.qmanager)||(userName===record.rmanager)?'operate_link_group text-nowrap text-color-red':"operate_link_group text-nowrap")}>
          {record.qmanager||record.rmanager}
         </div>
       }},
        {title: '更新人',width:120, dataIndex: 'updateBy', key: 'updateBy', align: 'center',render: (text, record) => {
          return  <div className={classNames(userName===text?'operate_link_group text-nowrap text-color-red':"operate_link_group text-nowrap")}>
          {text}
       </div>
       }},
        {title: '更新时间', dataIndex: 'updateTime', key: 'updateTime', align: 'center',width:150}
      ]
      case '6':
      return [
        {title: '名称',fixed:'left', dataIndex: 'bookName',width:250, key: 'bookName', align: 'center',render: (text, record) => {
          return <div className="operate_link_group text-nowrap text-link" onClick={()=>goInfo(record.id,'BOOK')}>
            {text}
         </div>
       }},
        {title: '状态', dataIndex: 'bookStatus',width:100, key: 'bookStatus', align: 'center'},
        {title: '封面', dataIndex: 'pictureUrl',width:150, key: 'pictureUrl', align: 'center',render:(text)=>{
          return  <div>
            {
              text?<Image
              width={60}
              src={text}
            />:''
            }
          </div>
        }},
        {title: '适合年纪', dataIndex: 'ageName',width:100, key: 'ageName', align: 'center'},
        {title: '主题', dataIndex: 'themes',width:180, key: 'themes', align: 'center', render: (text, record) => {
          return <div className="operate_link_group text-nowrap">
           {record.themes?.map((i,j)=>{
             return   <Tooltip key={i.id} placement="top" title={text.map(i=>i.themeName).join(' ')}>
              {
                j<3?<Tag key={i.id} color="lime">{i.themeName}</Tag>:''
              }
               </Tooltip>
           })}
         </div>}
        },
        {title: '系列', dataIndex: 'serialName',width:150, key: 'serialName', align: 'center'},
        {title: '标签', dataIndex: 'labels', key: 'labels',width:180, align: 'center', render: (text, record) => {
         return <div className="operate_link_group text-nowrap">
          {record.labels?.map((i,j)=>{
            return   <Tooltip key={i.id} placement="top" title={text.map(i=>i.labelName).join(' ')}>
             {
               j<3?<Tag key={i.id} color="green">{i.labelName}</Tag>:''
             }
              </Tooltip>
          })}
        </div>
        }},
        {title: '创建人',width:120, dataIndex: 'createBy', key: 'createBy', align: 'center',render: (text, record) => {
          return <div className={classNames(userName===text?'operate_link_group text-nowrap text-color-red':"operate_link_group text-nowrap")}>
            {text}
         </div>
        }},
        {title: '负责人',width:120, dataIndex: 'manager', key: 'manager', align: 'center', render: (text, record) => {
          return <div className={classNames((userName===record.qmanager)||(userName===record.rmanager)?'operate_link_group text-nowrap text-color-red':"operate_link_group text-nowrap")}>
          {record.qmanager||record.rmanager}
         </div>
        }},
        {title: '更新人',width:120, dataIndex: 'updateBy', key: 'updateBy', align: 'center',render: (text, record) => {
          return  <div className={classNames(userName===text?'operate_link_group text-nowrap text-color-red':"operate_link_group text-nowrap")}>
          {text}
       </div>
        }},
        {title: '更新时间', dataIndex: 'updateTime', key: 'updateTime', align: 'center',width:150},
      ]
      case '5':
      return [
        {title: '名称',fixed:'left', dataIndex: 'videoName',width:250, key: 'videoName', align: 'center',render: (text, record) => {
          return <div className="operate_link_group text-nowrap text-link" onClick={()=>goInfo(record.id,'VIDEO')}>
            {text}
         </div>
       }},
        {title: '状态', dataIndex: 'videoStatus',width:100, key: 'videoStatus', align: 'center'},
        {title: '封面', dataIndex: 'pictureUrl',width:150, key: 'pictureUrl', align: 'center',render:(text)=>{
          return  <div>
            {
              text?<Image
              width={60}
              src={text}
            />:''
            }
          </div>
        }},
        {title: '适合年纪', dataIndex: 'ageName',width:100, key: 'ageName', align: 'center'},
        {title: '发行方', dataIndex: 'publisher',width:150, key: 'publisher', align: 'center'},
        {title: '主题', dataIndex: 'themes',width:180, key: 'themes', align: 'center', render: (text, record) => {
          return <div className="operate_link_group text-nowrap">
           {record.themes?.map((i,j)=>{
             return   <Tooltip key={i.id} placement="top" title={text.map(i=>i.themeName).join(' ')}>
              {
                j<3?<Tag key={i.id} color="lime">{i.themeName}</Tag>:''
              }
               </Tooltip>
           })}
         </div>}
        },
        {title: '系列', dataIndex: 'serialName',width:150, key: 'serialName', align: 'center'},
        {title: '类型', dataIndex: 'videoCategoryName',width:150, key: 'videoCategoryName', align: 'center'},
        {title: '标签', dataIndex: 'labels', key: 'labels',width:180, align: 'center', render: (text, record) => {
         return <div className="operate_link_group text-nowrap">
          {record.labels?.map((i,j)=>{
            return   <Tooltip key={i.id} placement="top" title={text.map(i=>i.labelName).join(' ')}>
             {
               j<3?<Tag key={i.id} color="green">{i.labelName}</Tag>:''
             }
              </Tooltip>
          })}
        </div>
      }},
        {title: '创建人',width:120, dataIndex: 'createBy', key: 'createBy', align: 'center',render: (text, record) => {
          return <div className={classNames(userName===text?'operate_link_group text-nowrap text-color-red':"operate_link_group text-nowrap")}>
            {text}
         </div>
       }},
        {title: '负责人',width:120, dataIndex: 'manager', key: 'manager', align: 'center', render: (text, record) => {
          return <div className={classNames((userName===record.qmanager)||(userName===record.rmanager)?'operate_link_group text-nowrap text-color-red':"operate_link_group text-nowrap")}>
          {record.qmanager||record.rmanager}
         </div>
       }},
        {title: '更新人',width:120, dataIndex: 'updateBy', key: 'updateBy', align: 'center',render: (text, record) => {
          return  <div className={classNames(userName===text?'operate_link_group text-nowrap text-color-red':"operate_link_group text-nowrap")}>
          {text}
       </div>
       }},
        {title: '更新时间', dataIndex: 'updateTime', key: 'updateTime', align: 'center',width:150},
      ]
      case '7':
      return [
        {title: '名称',fixed:'left', dataIndex: 'bookName',width:250, key: 'bookName', align: 'center',render: (text, record) => {
          return <div className="operate_link_group text-nowrap text-link" onClick={()=>goInfo(record.id,'IR_BOOK')}>
            {text}
         </div>
       }},
        {title: '状态', dataIndex: 'bookStatus',width:100, key: 'bookStatus', align: 'center'},
        {title: '封面', dataIndex: 'pictureUrl',width:150, key: 'pictureUrl', align: 'center',render:(text)=>{
          return  <div>
            {
              text?<Image
              width={60}
              src={text}
            />:''
            }
          </div>
        }},
        {title: '适合年纪', dataIndex: 'ageName',width:100, key: 'ageName', align: 'center'},
        {title: '主题', dataIndex: 'themes',width:180, key: 'themes', align: 'center', render: (text, record) => {
          return <div className="operate_link_group text-nowrap">
           {record.themes?.map((i,j)=>{
             return   <Tooltip key={i.id} placement="top" title={text.map(i=>i.themeName).join(' ')}>
              {
                j<3?<Tag key={i.id} color="lime">{i.themeName}</Tag>:''
              }
               </Tooltip>
           })}
         </div>}
        },
        {title: '系列', dataIndex: 'serialName',width:150, key: 'serialName', align: 'center'},
        {title: '标签', dataIndex: 'labels', key: 'labels',width:180, align: 'center', render: (text, record) => {
         return <div className="operate_link_group text-nowrap">
          {record.labels?.map((i,j)=>{
            return   <Tooltip key={i.id} placement="top" title={text.map(i=>i.labelName).join(' ')}>
             {
               j<3?<Tag key={i.id} color="green">{i.labelName}</Tag>:''
             }
              </Tooltip>
          })}
        </div>
        }},
        {title: '创建人',width:120, dataIndex: 'createBy', key: 'createBy', align: 'center',render: (text, record) => {
          return <div className={classNames(userName===text?'operate_link_group text-nowrap text-color-red':"operate_link_group text-nowrap")}>
            {text}
         </div>
        }},
        {title: '负责人',width:120, dataIndex: 'manager', key: 'manager', align: 'center', render: (text, record) => {
          return <div className={classNames((userName===record.qmanager)||(userName===record.rmanager)?'operate_link_group text-nowrap text-color-red':"operate_link_group text-nowrap")}>
          {record.qmanager||record.rmanager}
         </div>
        }},
        {title: '更新人',width:120, dataIndex: 'updateBy', key: 'updateBy', align: 'center',render: (text, record) => {
          return  <div className={classNames(userName===text?'operate_link_group text-nowrap text-color-red':"operate_link_group text-nowrap")}>
          {text}
       </div>
        }},
        {title: '更新时间', dataIndex: 'updateTime', key: 'updateTime', align: 'center',width:150},
      ]
      case '8':
      return [
        {title: '试卷名称', dataIndex: 'paperName', key: 'paperName', align: 'center',render: (text, record) => {
          return <div className="operate_link_group text-nowrap text-link" onClick={()=>goInfo(record.id,'PAPER')}>
            {text}
         </div>
       }},
        {title: '分类', dataIndex: 'type', key: 'type', align: 'center',render: (text, record) => {
          return <div className="operate_link_group">
            {text===1?'定级测试':'升级测试'}
         </div>
       }},
        {title: '题数', dataIndex: 'subjectCount', key: 'subjectCount', align: 'center'},
        {title: '状态', dataIndex: 'paperStatus', key: 'paperStatus', align: 'center'},
        {title: '创建人', dataIndex: 'createBy', key: 'createBy', align: 'center',render: (text, record) => {
          return <div className={classNames(userName===text?'operate_link_group text-nowrap text-color-red':"operate_link_group text-nowrap")}>
            {text}
         </div>
       }},
        {title: '负责人', dataIndex: 'manager', key: 'manager', align: 'center', render: (text, record) => {
          return <div className={classNames((userName===record.qmanager)||(userName===record.rmanager)?'operate_link_group text-nowrap text-color-red':"operate_link_group text-nowrap")}>
          {record.qmanager||record.rmanager}
         </div>
       }},
        {title: '更新人', dataIndex: 'updateBy', key: 'updateBy', align: 'center',render: (text, record) => {
          return  <div className={classNames(userName===text?'operate_link_group text-nowrap text-color-red':"operate_link_group text-nowrap")}>
          {text}
       </div>
       }},
        {title: '更新时间', dataIndex: 'updateTime', key: 'updateTime', align: 'center',width:150},
        {title: '编辑', dataIndex: 'active', key: 'active', align: 'center',width:100,render:(text, record) => {
          return  <>
           <span className="text-link">预览</span>&nbsp;&nbsp;&nbsp;
          </>
        }}
      ]
      case '9':
      return [
        {title: '名称',fixed:'left', dataIndex: 'lessonName',width:150, key: 'lessonName', align: 'center',render: (text, record) => {
          return <div className="operate_link_group text-nowrap text-link" onClick={()=>goInfo(record.id,'LESSON')}>
            {text}
         </div>
       }},
        {title: '级别', dataIndex: 'levelName',width:50, key: 'levelName', align: 'center'},
        {title: '状态', dataIndex: 'lessonStatus',width:50, key: 'lessonStatus', align: 'center'},
        {title: '课程ID', dataIndex: 'lessonCode',width:150, key: 'lessonCode', align: 'center'},
        {title: '字母', dataIndex: 'letter',width:100, key: 'letter', align: 'center'},
        {title: '词汇', dataIndex: 'words',width:150, key: 'words', align: 'center'},
        {title: '题数', dataIndex: 'count',width:50, key: 'count', align: 'center'},
        {title: '拼读单词', dataIndex: 'lessonReading',width:150, key: 'lessonReading', align: 'center'},
        {title: '句型', dataIndex: 'sentencePattern',width:150, key: 'sentencePattern', align: 'center'},
        {title: '目标描述', dataIndex: 'remark',width:150, key: 'remark', align: 'center'},
        {title: '创建人',width:120, dataIndex: 'createBy', key: 'createBy', align: 'center',render: (text, record) => {
          return <div className={classNames(userName===text?'operate_link_group text-nowrap text-color-red':"operate_link_group text-nowrap")}>
            {text}
         </div>
        }},
        {title: '负责人',width:120, dataIndex: 'manager', key: 'manager', align: 'center', render: (text, record) => {
          return <div className={classNames((userName===record.qmanager)||(userName===record.rmanager)?'operate_link_group text-nowrap text-color-red':"operate_link_group text-nowrap")}>
          {record.qmanager||record.rmanager}
         </div>
        }},
        {title: '更新人',width:120, dataIndex: 'updateBy', key: 'updateBy', align: 'center',render: (text, record) => {
          return  <div className={classNames(userName===text?'operate_link_group text-nowrap text-color-red':"operate_link_group text-nowrap")}>
          {text}
       </div>
        }},
        {title: '更新时间', dataIndex: 'updateTime', key: 'updateTime', align: 'center',width:150},
      ]
      default:
      return []
    }
  },
    // 开始
    startProgress() {
        Nprogress['start']();
    },
    // 结束
    endProgress() {
        Nprogress['done']();
    },
    /**
     * 下载文件
     * @param item
     * @returns {string}
     */
    downloadFile(item) {
        return item ? `${this.url}file/download?bucketName=${item['bucketName']}&fileId=${item.fileUrl}` : '';
    },

    /**
     * 字符串截取
     * @param info
     * @param num
     * @returns {string|*}
     */
    fontSplit(info, num) {
        if (info.length > num) {
            return info.substr(0, num) + '...';
        } else {
            return info;
        }
    },
    /**
     * 判断用户登录状态
     * @returns {boolean}
     */
    judgeUserLoginStatus() {
        // return !!this.getCookies('token');
        return true
    },
    /**
     * 退出登录
     */
    logOutService() {
        // store.dispatch({type: 'isLogin', payload: false});
    },
    /**
     * 切割数组，把一个数据分割成多个组
     * @param array
     * @param subGroupLength
     * @returns {[]}
     */
    arraySlice(array, subGroupLength) {
        let index = 0;
        let newArray = [];
        while (index < array.length) {
            newArray.push(array.slice(index, index += subGroupLength));
        }
        return newArray;
    },
   
    /**
     * 根据Value获取key
     * @param obj
     * @param value
     * @returns {string}
     */
    getValueByKey(obj, value) {
        for (const objKey in obj) {
            if (obj.hasOwnProperty(objKey)) {
                if (obj[objKey] === value) {
                    return objKey;
                }
            }
        }
    },
    /**
     * 根据Key获取Value
     * @param obj
     * @param key
     * @returns {string}
     */
    getKeyByValue(obj, key) {
        for (const objKey in obj) {
            if (obj.hasOwnProperty(objKey)) {
                if (parseInt(objKey) === key) {
                    return obj[objKey];
                }
            }
        }
    },

    /**
     * 删除弹窗
     * @param text
     * @param okCallback
     * @param noCallback
     */
    deleteModelWindow(okCallback, noCallback, text) {
        confirm({
            icon: <AlignCenterOutlined style={{color: 'red'}}/>,
            content: '确定删除' + (text || '') + '吗？',
            centered: true,
            okText: '确定',
            cancelText: '取消',
            onOk: okCallback,
            onCancel: noCallback
        });
    },
   
    /*正确错误提示*/
    messageService(msg, callback, text) {
        let result = msg.code.toString() === '200';
        if (result) {
            message.success({content: text + '成功', key: 'logout'});
        } else {
            message.error({content: text + '失败', key: 'logout'});
        }
        if (callback) callback(result);
    },
    /*自定义正确错误提示*/
    messageCustomService(msg, callback, noMsg) {
        let result = msg.code.toString() === '200';
        if (result) {
            if (!noMsg) message.success({content: msg.message || msg.msg, key: 'custom_msg'});
        } else {
            message.error({content: msg.message || msg.msg, key: 'custom_msg'});
        }
        if (callback) callback(result);
    },
    /*获取当前导航模块*/
    getCurrentNavActive(navList, default_nav) {
        let hash = window.location.hash;
        let subHash = hash.substring(0, hash.lastIndexOf('?'));
        if (subHash) {
            hash = subHash
        }
        let hashArr = hash.split('/');

        let active = default_nav;
        for (let i = 0; i < navList.length; i++) {
            let path = navList[i].path;
            for (let j = 0; j < hashArr.length; j++) {
                if (hashArr[j] === path) {
                    active = path;
                }
            }
        }
        return active;
    },
    // /*获取用户列表*/
    // getUserList(callback) {
    //     this.validateTokenLoadData('user/list', null, msg => callback(msg.data))
    // },
    // /*获取单位列表*/
    // getUnitList(callback) {
    //     this.ajaxNoFileMethods('workunit/list', null, msg => callback(msg.data));
    // },
    // /*获取角色列表*/
    // getRoleList(callback) {
    //     this.validateTokenLoadData('role/list', null, msg => callback(msg.data));
    // },

    /**
     * 验证手机号重复
     * @param params
     * @param callback
     */
    validateMobile(params, callback) {
     
    },

    /**
     * 校验规则
     * @param {*} type 
     * @returns 
     */
    checkRules(type) {
        switch(type) {
            case 'loginName' :
                return ([{ 
                    required: true, 
                    message: '账号必须填'
                  }])
            case 'password' :
                return ([{ 
                    required: true, 
                    message: '密码必须填'
                  }])
            case 'idCard' :
                return ([{ 
                    required: true, 
                    pattern: /^(^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$)|(^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])((\d{4})|\d{3}[Xx])$)$/,
                    message: '身份证格式不正确',
                }])
            case 'creditCode' :
                return ([{
                    required: true,
                    message: '税号长度必须是18位',
                    len: 18
                }])
            case 'null' :
                return ([{
                    required: true,
                    message: '你的输入为空',
                }])
            case 'number' :
                return ([{
                    required: true,
                    pattern: /^\+?[1-9][0-9]*$/,
                    message: '请输入正确的数字'
                }])
            case 'name' :
                return ([{
                    required: true,
                    pattern: /^[\u2E80-\u9FFF]+$/,
                    message: '请输入汉字姓名'
                }])
            default :
                return;
        }
    },
      /**
     * 判断是否手机登录
     * @returns 
     */
     isPhoneLogin(){
       return window.navigator.appVersion.indexOf('Mobile')!==-1
     },
   

    /*添加文件到formData*/
    appendFileToFormData(obj, formData) {
        for (let i = 0; i < obj.files.length; i++) {
            if (!obj.files[i].id) {
                formData.append('files', obj.files[i]);
            }
        }
    },

    /*获取当前导航模块*/
    getHeadCurrentModule() {
        return this.getCurrentNavActive(this.options.navList)
    },
    /**
     * 导出echarts图表为图片
     * @param charts
     * @param pixelRatio 导出的图片分辨率比率 默认3
     */
    exportChartsImage(charts, pixelRatio) {
        let url = charts.getConnectedDataURL({
            pixelRatio: pixelRatio || 3,　　//导出的图片分辨率比率,默认是1
            backgroundColor: '#fff',　　//图表背景色
            type: 'png',
            excludeComponents: [　　//保存图表时忽略的工具组件,默认忽略工具栏
                'toolbox'
            ]
        });
        let a = document.createElement('a');
        a.download = new Date().getTime().toString();
        a.href = url;
        a.target = '_blank';
        document.body.append(a);
        a.click();
        a.remove();
    },
    /**
     * 计算数组总和
     * @param msg
     * @returns {number}
     */
    countArrayTotal(msg) {
        let count = 0;
        for (let i = 0; i < msg.length; i++) {
            count += parseFloat(msg[i]);
        }
        return count;
    },
   
    /**
     * 导出表格数据为excel
     * @param columns
     * @param dataSource
     * @param fileName
     */
    exportExcel(columns, dataSource, fileName) {
        // let sheetFilter = [], sheetHeader = [];
        // for (let i = 0; i < columns.length; i++) {
        //     sheetHeader.push(columns[i].title);
        //     sheetFilter.push(columns[i].dataIndex);
        // }
        // let options = {
        //     fileName: fileName || new Date().getTime(),
        //     datas: [
        //         {
        //             sheetData: dataSource,
        //             sheetName: 'sheet',
        //             sheetFilter,
        //             sheetHeader
        //         }
        //     ]
        // }
        // let toExcel = ExportJsonExcel({...options});
        // toExcel.saveExcel();
    },
    /**
     * 下载服务接口
     * @param url
     * @param params
     */
    downloadService(url, params) {
        let data = [];
        for (const paramsKey in params) {
            if (params.hasOwnProperty(paramsKey)) {
                data.push(paramsKey + '=' + params[paramsKey]);
            }
        }
        let elem = document.createElement("a");
        elem.href = this.url + url + '?' + data.join("&");
        elem.download = new Date().getTime().toString();
        document.body.append(elem);
        elem.click();
        elem.remove();
    },
    /**
     * 过滤文件返回集合
     * @param msg
     * @returns {{文档: [], 图片: [], 其它: [], 视频: [], 音频: []}}
     */
    filterFilterReturnList(msg) {
        msg = msg || [];
        let imagesArr = [], videoArr = [], audioArr = [], docArr = [], otherArr = [];
        const {image, video, audio, doc} = this.options.regex;
        for (let i = 0; i < msg.length; i++) {
            let item = msg[i];
            const {type} = item;
            let fileType = type.toLowerCase();
            if (image.test(fileType)) { // 图片过滤
                imagesArr.push(item);
            } else if (video.test(fileType)) { // 视频过滤
                videoArr.push(item);
            } else if (audio.test(fileType)) { // 音频过滤
                audioArr.push(item);
            } else if (doc.test(fileType)) { // 文档过滤
                docArr.push(item);
            } else { // 其它过滤
                otherArr.push(item);
            }
        }
        return {
            '\u56fe\u7247': imagesArr,
            '\u89c6\u9891': videoArr,
            '\u97f3\u9891': audioArr,
            '\u6587\u6863': docArr,
            '\u5176\u5b83': otherArr
        };
    },
    /*计算视频时长*/
    countVideoDuration(duration) {
        let minute = parseInt((duration % 3600) / 60);
        if (minute < 10) {
            minute = "0" + minute;
        }
        let second = (Math.floor(duration % 60) / 100).toString();
        second = second.substring(second.lastIndexOf('.') + 1);
        second = parseInt(second);
        if (second < 10) {
            second = "0" + second;
        }
        return minute + ':' + second;
    }
};
export default commonConfig;